import java.util.Scanner;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 28318
 * Date: 2025-10-31
 * Time: 20:31
 */


public class Main {

    public static void main(String[] args) {
        int[] B = {1, 3, 5};
        int n = B.length;
        int[] A = {2, 4, 0, 0, 0};
        int m = A.length - n;


        merge(A, m, B, n);
//        String str = "BAabB";
//        System.out.println(setstring(str));
    }

    public static void merge(int A[], int m, int B[], int n) {
        int[] newNum = new int[m];
        for (int i = 0; i < m; i++) {
            newNum[i] = A[i];
        }
        for (int i = 0, j = 0, k = 0; k < m + n && m != 0 && n != 0; k++) {
            if (i == -1){
                A[k] = B[j];
                if (j < n - 1){
                    j++;
                } else if (j == n - 1) {
                    j = -1;
                }
            } else if (j == -1) {
                A[k] = newNum[i];
                if (i < m - 1){
                    i++;
                } else if (i == m - 1) {
                    i = -1;
                }
            } else if (newNum[i] >= B[j]){
                A[k] = B[j];
                if (j < n - 1){
                    j++;
                } else if (j == n - 1) {
                    j = -1;
                }
            } else if (newNum[i] < B[j]){
                A[k] = newNum[i];
                if (i < m - 1){
                    i++;
                } else if (i == m - 1) {
                    i = -1;
                }
            }
        }
        if (m == 0){
            for (int i = 0; i < m + n; i++) {
                A[i] = B[i];
            }
        }
        for (int i : A) {
            System.out.print(i);
        }
//        System.out.println(A.toString());
    }

    public static boolean charLastSearch(String str, char ch) {
        boolean ret = false;
        for (int i = 0, j = str.length() - i - 1; i < j ; i++) {
            if (str.charAt(i) == ch | str.charAt(j) == ch) {
                ret = true;
                break;
            }
        }
        return ret;
    }

    public static String setstring (String str) {
        Scanner inPut = new Scanner(System.in);
        String str2 = new String();
        str2 += str.charAt(0);
        for (int i = 1; i < str.length(); i++) {
            if (!charLastSearch(str2,str.charAt(i))){
                str2 += str.charAt(i);
            }
        }
        return str2;
    }

}